<!DOCTYPE html>
<html>

<head>
    {include file="Public/header"}
    <style>
        .agencyM_table tr th {
            text-align: center;
        }

        .textR {
            text-align: right;
        }

        .td2 {
            min-width: 140px
        }
    </style>
</head>

<body class="white-bg" style="color:#333;padding:0px;">

   <div class="page-heade">
       <h2 class="title_color text-center">网点详情</h2>
    </div>
    {include file="net/view_common"}

    <div class="" style="padding: 0">
        <div class="" style="padding: 8px">
            <button class="btn btn-success {if request()->get('yituichang')==1}btn-outline{/if}" id="yijinchang">已进场</button>
            <button class="btn btn-success  {if request()->get('yituichang')!=1}btn-outline{/if}" id="yituichang">已退场</button>
            <button class="btn btn-primary btn-outline ">导入网点已进场条码</button>
        </div>
        <table class="table agencyM_table table-bordered table-hover">
            <tr class="info">
                <th>序号</th>
                <th>状态</th>
                <th>重复进场</th>
                <th>单品名称</th>
                <th>SKU</th>
                <th>进场时间</th>
                <th>进场费(元)</th>
                <th>卖场零售价(元)</th>
                <th>库存数量</th>
                <th>上月销量</th>
                <th>累计销量</th>
                <th>退场时间</th>
                <th>备注</th>
                <th><button class="btn  btn-primary" id="addbar">添加</button></th>
            </tr>
            {volist name="barcode" id="row" key="k"}
            <tr>
                <td>{$k}</td>
                <td>{if $row.tuichang==1}已退场{else}正常{/if}</td>
                <td>{if $row.is_repeat==1}是{else}否{/if}</td>
                <td>{$row.prod}</td>
                <td>{$row.pro_sku}</td>
                <td>{:date('Y-m-d',$row.intime)}</td>
                <td>{$row.infee}</td>
                <td>{$row.retailPrice}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>
                    {if request()->get('yituichang')!=1}
                    <button class="btn  btn-default tuichang" data-id="{$row.id}" data-title="{$row.prod}" data-intime="{$row.intime}">退场</button><br>
                    {/if}
                    <button class="btn  btn-default weihu" data-status="{$row.status}" data-id="{$row.id}" data-title="{$row.prod}" data-intime="{$row.intime}" style="margin-top:5px;">维护</button><br>
                    <button class="btn  btn-default chakanhuibao" data-id="{$row.id}"  style="margin-top:5px;">查看汇报</button>
                </td>
            </tr>
            {/volist}

        </table>
        <form action="" id="add" method="post"></form>
        <input type="hidden" id="bar_id"  value="">

    </div>


    <!-- 全局js -->
    {include file="Public/footer"}
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>

<script>
    $(function(){
        //修改联系人
        $('#updateContact').on('click',function () {
            layer.open({
                type:2,
                title:'修改',
                area:['95%','80%'],
                content:'{:url("form_contact",array("id"=>$data.id))}'
            })
            return false
        })
        var index
        $('#yijinchang').on('click',function(){
            var action = $('#add').attr('action')

            location.href = '{:url("view6",array("id"=>request()->param("id")))}'
        })
        $('#yituichang').on('click',function(){
            var action = $('#add').attr('action')

            location.href = action+'?yituichang=1'
        })
        //退场
        $('.tuichang').on('click',function(){
            var id = $(this).data('id')
            var title = $(this).data('title')
            var intime = $(this).data('intime')
            $('#bar_id').val(id)
            var str = '<div class="ibox" id="tuichang" ' +
                    '<div class="ibox-title" style="text-align: center;"><h3>条码退场</h3></div> ' +
                    '<div class="ibox-content"> ' +
                    '<table class="table table-bordered"> ' +
                    '<tr> <td>条码名称</td> <td>'+title+'</td> ' +
                    '<td>进场时间</td>' +
                    '<td>'+intime+'</td>' +
                    '</tr>' +
                    '<tr>' +
                    '<td>退场时间</td>' +
                    ' <td><input type="text" onclick="laydate()" id="tuichangshijian" class="form-control"></td>' +
                    '<td>退场原因</td>' +
                    '<td><input type="text" class="form-control" id="tuichangyuanyin" class="form-control"></td>' +
                    '</tr>' +
                    '</table>' +
                    '<div class="text-center">' +
                    '<button id="baocun" class="btn btn-primary">保存</button>&nbsp;' +
                    '<button id="fanhui" class="btn btn-primary">返回</button>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
               index = layer.open({
                type:1,
                title:'退场',
                area:['60%','60%'],
                fixed:false,
                maxmin:true,
                content:str
            })
        })

        //维护
        $('.weihu').on('click',function(){
            var id = $(this).data('id')
            var title = $(this).data('title')
            var intime = $(this).data('intime')
            var status = $(this).data('status')
            var checked = status==0?'checked':''
            var checked2 = status==1?'checked':''
            var checked3 = status==2?'checked':''
            $('#bar_id').val(id)
            var radio = '<input type="radio" class="status" name="status" value="0" '+checked+'>正常&nbsp;&nbsp;' +
                    '<input type="radio" class="status" name="status" value="1" '+checked2+'>锁码&nbsp;&nbsp;' +
                    '<input type="radio" class="status" name="status" value="2" '+checked3+'>缺货&nbsp;&nbsp;'
            var str = '<div class="ibox" id="weihu" ' +
                    '<div class="ibox-title" style="text-align: center;"><h3>维护进场条码</h3></div> ' +
                    '<div class="ibox-content"> ' +
                    '<table class="table table-bordered"> ' +
                    '<tr> <td>条码名称</td> <td>'+title+'</td> ' +
                    '<td>进场时间</td>' +
                    '<td>'+intime+'</td>' +
                    '</tr>' +
                    '<tr>' +
                    '<td>条码状态</td>' +
                    '<td colspan="3">'+radio+'</td>' +
                    '</tr>' +
                    '</table>' +
                    '<div class="text-center">' +
                    '<button id="baocun2" class="btn btn-primary">提交</button>&nbsp;' +
                    '<button id="fanhui" class="btn btn-primary">取消</button>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
               index = layer.open({
                type:1,
                title:'退场',
                area:['60%','60%'],
                content:str
            })
        })
        //退场保存
        $('body').on('click','#baocun',function(){
            var tuichangshijian = $('#tuichangshijian').val()
            var tuichangyuanyin = $('#tuichangyuanyin').val()
            var bar_id = $('#bar_id').val()
            $.post($('#add').attr('action'),{tuichangshijian:tuichangshijian,tuichangyuanyin:tuichangyuanyin,bar_id:bar_id},function(data){
                if(data.success){
                    swal(data.msg,'--','success');
                    layer.close(index)

                }else{
                    swal(data.msg,'--','error');
                }
            },'json')
        })
        //维护保存
        $('body').on('click','#baocun2',function(){
            var status = $('input.status:checked').val()
            var bar_id = $('#bar_id').val()
            $.post($('#add').attr('action'),{status:status,bar_id:bar_id,a:2},function(data){
                if(data.success){
                    swal(data.msg,'--','success');
                    layer.close(index)

                }else{
                    swal(data.msg,'--','error');
                }
            },'json')
        })
        //返回
        $('body').on('click','#fanhui',function(){
            layer.close(index)
        })
        //添加
        $('#addbar').click(function () {
            top.layer.open({
                type: 2,
                title: '添加',
                area: ['60%', '60%'],
                fixed: false, //不固定
                maxmin: true,
                content: '{:url("form_barcode",["id"=>request()->param("id")])}'
            });
            return false
        })

        //查看汇报
        $('.chakanhuibao').click(function () {
            top.layer.open({
                type: 2,
                title: '查看汇报',
                area: ['60%', '60%'],
                fixed: false, //不固定
                maxmin: true,
                content: $('#add').attr('action')+'?chakanhuibao=1'
            });
            return false
        })
    })
</script>
</body>

</html>